home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1990-10-05 | 15.7 KB | 564 lines | [ TEXT/MPS ]
# # File: SelfTour.vu # # Contains: A VU self-tour script to be run against MacPaint 2.0 # # Before running this script, MacPaint must be launched. # This script creates two documents called 'VU Speaks' and 'Diagram' which # are deleted at the end of the script. # # Conventions: Global variables begin with a capital letter # # Written by: Jay Jessen # # Copyright: © 1990 by Apple Computer, Inc., all rights reserved. # # Change History: # # 5/17/90 JAS Create globals Number_of_moves and Max_mouse_speed. A few small # changes in comment header. # # 11/7/89 Jay creation # # To Do: # # ******************************************************************************************** # Select a tool from the "Tools" pallette task select_tool_from_menubar(paint_tool) begin old_speed := mouseSpeed(2); move a : { 360,10 }; wait(1); pressMouse; move absolute: { ((paint_tool[2]) * 23) + 341,((paint_tool[1]) * 20) + 58 }; wait(1); releaseMouse; global Current_tool := paint_tool; mouseSpeed(old_speed); end; # ******************************************************************************************** # Tear off the "Tools" pallette task tear_off_tool_pallette() begin old_speed := mouseSpeed(2); move absolute: { 360,10 }; wait(1); pressMouse; wait(1); for i := 1 to 200 step 50 move relative: { 0,50 }; releaseMouse; mouseSpeed(old_speed); end; # ******************************************************************************************** task close_tool_pallette() begin if match[window t:'Tool' r:?pal_rect]! begin old_speed := mouseSpeed(2); move absolute: { pal_rect[1] + 11,pal_rect[2] + 5 }; wait(1); click; mouseSpeed(old_speed); end; end; # ******************************************************************************************** # Tear off the Tools pallette (if not already torn off) and position it against the Diag window. task position_tear_off_tool_pallette() begin global Diagram_wind_title; if(not match[window t:'Tool']!) tear_off_tool_pallette(); winder := match[window t:/?{Diagram_wind_title}≈/]!; match [window t:'Tool' r:?tool_rect]!; drag [window t:'Tool']! absolute: { winder.rect[3] - (tool_rect[3] - tool_rect[1]), winder.rect[4] - (tool_rect[4] - tool_rect[2]) }; end; # ******************************************************************************************** task position_cursor_over_floating_tool(paint_tool) begin if(not match[window t:'Tool']!) position_tear_off_tool_pallette(); match [window t:'Tool' r:?tool_rect]!; old_speed := mousespeed(2); move absolute: { (tool_rect[1] + 12) + (paint_tool[2] * 23), (tool_rect[2] + 48) + (paint_tool[1] * 20)}; mousespeed(old_speed); end; # ******************************************************************************************** task select_tool_from_floating_tool_pallette(paint_tool) begin position_cursor_over_floating_tool(paint_tool); click; global current_tool := paint_tool; end; # ******************************************************************************************** task select_tool(paint_tool) begin if(match[window t:'Tool']!) select_tool_from_floating_tool_pallette(paint_tool); else select_tool_from_menubar(paint_tool); end; # ******************************************************************************************** task double_click_tool_from_floating_tool_pallette(paint_tool) begin position_cursor_over_floating_tool(paint_tool); doubleClick; end; # ******************************************************************************************** task select_pattern_from_menubar(pattern_column,pattern_row) begin old_speed := mouseSpeed(2); move a : { 260,19 }; wait(1); pressMouse; move relative: { (pattern_column * 20) + 10,(pattern_row * 17) + 8 }; wait(1); releaseMouse; mouseSpeed(old_speed); end; # ******************************************************************************************** task select_file(path,depth := 32) begin pressKey keystrokes: { commandKey }; for i := 1 to depth begin type keystrokes: { uparrowKey }; end; releaseKey keystrokes: { commandKey }; for each path_element in path begin type keystrokes: { path_element,returnKey }; end; end; # ******************************************************************************************** task open_file(path,depth := 32) begin select [menuItem t:/Open≈/ m:'File']; select_file(path,depth); end; # ******************************************************************************************** task draw_mac_icon(x,y) begin global pencil; global frame_rect; global shade_rect; # compute the body frame mac_frame := { x,y,x + 50,y + 51 }; # draw the body frame select_tool(frame_rect); old_speed := mouseSpeed(2); move absolute: { mac_frame[1],mac_frame[2] }; pressMouse; move relative: { 50,51 }; wait(1); releaseMouse; # draw the base move absolute: { mac_frame[1] + 2,mac_frame[4] }; pressMouse; move relative: { 46,11 }; wait(1); releaseMouse; # draw the screen move absolute: { mac_frame[1] + 6,mac_frame[2] + 6 }; pressMouse; move relative: { 38,3 }; wait(1); releaseMouse; select_pattern_from_menubar(3,0); # select the ltGray pattern (standard desktop pattern) select_tool(shade_rect); move absolute: { mac_frame[1] + 6,mac_frame[2] + 9 }; wait(1); pressMouse; move relative: { 38,24 }; wait(1); releaseMouse; select_tool(pencil); move absolute: { mac_frame[3] - 7,mac_frame[4] - 11 }; wait(1); pressMouse; move relative: { -15,0 }; wait(1); releaseMouse; mouseSpeed(old_speed); end; # ******************************************************************************************** task touch_up_mac_icon(x,y) begin global pencil,current_tool; activate_diagram_window(); if((current_tool[1] <> pencil[1]) or (current_tool[2] <> pencil[2])) begin select_tool(pencil); end; old_speed := mouseSpeed(2); move absolute: { x,y }; click; wait(1); move relative: { 50,0 }; click; wait(1); move relative: { 0,51 }; click; wait(1); move relative: { -50,0 }; click; wait(1); move relative: { 2,11 }; click; wait(1); move relative: { 46,0 }; click; wait(1); move relative: { -42,-56 }; click; wait(1); move relative: { 38,0 }; click; wait(1); move relative: { 0,27 }; click; wait(1); move relative: { -38,0 }; click; wait(1); mouseSpeed(old_speed); end; # ******************************************************************************************** task select_mac_icon(x,y) begin global marquee; activate_diagram_window(); select_tool(marquee); old_speed := mouseSpeed(2); move absolute:{ x,y }; wait(1); pressMouse; move relative: { 50,62 }; wait(1); releaseMouse; mouseSpeed(old_speed); end; # ******************************************************************************************** task move_mac_icon(at,move_to) begin activate_diagram_window(); select_mac_icon(at[1],at[2]); old_speed := mouseSpeed(2); move absolute: { at[1],at[2] }; wait(1); pressMouse; move absolute: { move_to[1],move_to[2] }; wait(1); releaseMouse; mouseSpeed(old_speed); end; # ******************************************************************************************** task copy_mac_icon(at,move_to) begin activate_diagram_window(); select_mac_icon(at[1],at[2]); old_speed := mouseSpeed(2); move absolute: { at[1],at[2] }; wait(1); pressKey keystrokes: { optionKey }; pressMouse; move absolute: { move_to[1],move_to[2] }; wait(1); releaseMouse; mouseSpeed(old_speed); releaseKey keystrokes: { optionKey }; end; # ******************************************************************************************** task center_text() begin match [menuItem m:'Style' t:'Align Middle' c:?checked]!; if(checked = '') begin select [menuItem m:'Style' t:'Align Middle']!; end; end; # ******************************************************************************************** task type_text(message_text) begin global text_tool,Text_wind_title,current_tool; winder := match[window t:/?{Text_wind_title}≈/]!; activate_text_window(); text_length := card(message_text); if((current_tool[1] <> text_tool[1]) or (current_tool[2] <> text_tool[2])) begin select_tool(text_tool); end; center_click_x := (winder.rectangle[3] - winder.rectangle[1] - 16) / 2; center_click_y := ((winder.rectangle[4] - winder.rectangle[2] - 34) / 2) + 18 + winder.rectangle[2]; old_speed := mouseSpeed(2); move absolute: { center_click_x,center_click_y }; click; mouseSpeed(old_speed); type keystrokes: { message_text }; end; # ******************************************************************************************** task select_font_and_style(font_selection := 'Geneval',style_selection := '9 point') begin select [menuItem t:font_selection m:'Font']!; select [menuItem t:style_selection m:'Style']!; end; # ******************************************************************************************** task activate_diagram_window() begin global Diagram_wind_title; # window number 1 global Text_wind_title; # window number 2 if match[window t:'Tool']! begin front := 2; back := 3; end; else begin front := 1; back := 2; end; match[window o:front rect:?front_rect]!; match[window o:back rect:?back_rect]!; if (front_rect[2] > back_rect[2]) begin select [window o:back]!; end; end; # ******************************************************************************************** task activate_text_window() begin global Diagram_wind_title; # window number 1 global Text_wind_title; # window number 2 if match[window t:'Tool']! begin front := 2; back := 3; end; else begin front := 1; back := 2; end; match[window o:front rect:?front_rect]!; match[window o:back rect:?back_rect]!; if (front_rect[2] < back_rect[2]) begin select [window o:back]!; end; end; # ******************************************************************************************** task save_as(window_number,replace_existing_selection := 'No') begin global Diagram_wind_title; # window number 1 global Text_wind_title; # window number 2 if (window_number = 1) begin current_title := Diagram_wind_title; activate_diagram_window(); end; else begin current_title := Text_wind_title; activate_text_window(); end; select [menuItem t:/Save As≈/ m:'File']; count := 0; made_unique := false; while match [window ord:1 style:dialog]! begin match[editText t:?editable_text w:[window ord:1 style:dialog]]!; if editable_text begin for i := 1 to card(editable_text) type keystrokes: { backspaceKey }; end; type keystrokes: { current_title }; if(count) type keystrokes: { "-",count }; select [button t:'Save' wind:[window ord:1]]!; if( match[button t:'Yes' w:[window ord:1 style:dialog]] and match[button t:'No' w:[window ord:1 style:dialog]] and match[staticText t:/Replace existing≈/ w:[window ord:1 style:dialog]] ) begin select [button t:replace_existing_selection w:[window ord:1 s:dialog]]!; end; if (window_number = 1) begin match[editText t:?Diagram_wind_title w:[window ord:1 style:dialog]]; current_title := Diagram_wind_title; end; else begin match[editText t:?Text_wind_title w:[window ord:1 style:dialog]]; current_title := Text_wind_title; end; count := count + 1; end; end; # ******************************************************************************************** task tile_and_title_windows(picture_percentage := 75) begin window_count := card(collect[window]); if window_count > 2 begin for i := 1 to window_count - 2 begin close [window]; end; end; else begin if window_count begin if window_count = 1 begin select [menuItem t:/New≈/ m:'File']; end; end; else begin select [menuItem t:/New≈/ m:'File']; select [menuItem t:/New≈/ m:'File']; end; end; picture_height := (338 * picture_percentage) / 100; drag [window] absolute: { 0,20 }; size [window] height:picture_height w:512; select [window ord:2]; size [window] height:338 - picture_height w:512; drag [window] absolute: { 0,picture_height + 4 }; end; # ******************************************************************************************** task erase_text_window() begin global eraser; activate_text_window(); double_click_tool_from_floating_tool_pallette(eraser); end; # ******************************************************************************************** task pause_then_erase_text(duration) begin wait(duration); erase_text_window(); end; # ******************************************************************************************** task close_all_windows_without_saving() begin close_tool_pallette(); while match[window] begin close [window]; if match[window s:dialog k:{[button t:'Yes'],[button t:'Cancel'],[button t:'No']}]! begin select [button t:'No' w:[window o:1]]!; end; end; end; # ******************************************************************************************** task label_mac_icon(x,y,label) begin global text_tool,current_tool; activate_diagram_window(); if((current_tool[1] <> text_tool[1]) or (current_tool[2] <> text_tool[2])) begin select_tool(text_tool); end; old_speed := mouseSpeed(2); move absolute: { x + 25,y + 79 }; click; mouseSpeed(old_speed); type keystrokes:{ label }; end; ##### EXECUTION STARTS HERE ###### # the following is a list of parameters that can be passed to select_tool() marquee := { 0,0 }; lasso := { 0,1 }; frame_rect := { 0,2 }; shade_rect := { 0,3 }; hand := { 1,0 }; line := { 1,1 }; frame_round_rect := { 1,2 }; shade_round_rect := { 1,3 }; pail := { 2,0 }; spray_can := { 2,1 }; frame_oval := { 2,2 }; shade_oval := { 2,3 }; brush := { 3,0 }; pencil := { 3,1 }; frame_region := { 3,2 }; shade_region := { 3,3 }; text_tool := { 4,0 }; eraser := { 4,1 }; frame_polygon := { 4,2 }; shade_polygon := { 4,3 }; patience(2); Pause_between_frames := 1; Diagram_wind_title := 'Diagram'; Text_wind_title := 'VU Speaks'; close_all_windows_without_saving(); tile_and_title_windows(50); save_as(1,'Yes'); save_as(2,'Yes'); select_tool(text_tool); current_tool := text_tool; center_text(); # Set font and size if (not ((match[menuItem t:'Chicago' m:'Font']).checked)) select [menuItem t:'Chicago' m:'Font']; if (not ((match[menuItem t:'12' m:'Style']).checked)) select [menuItem t:'12' m:'Style']; # Type some introductory text type_text("Hello, I am your Virtual User∂nHelping you test software at the human interface level is my life"); pause_then_erase_text(Pause_between_frames); type_text("I run over Appletalk so I need at least 2 machines"); pause_then_erase_text(Pause_between_frames); type_text("One to run the VU software∂n--for now this is the VU Tool within MPW"); # Draw, label, and touch up Mac icon activate_diagram_window(); match [window t:/?{Diagram_wind_title}≈/ r:?rect]!; rect := { rect[1] + 50,rect[2] + 38 }; draw_mac_icon(rect[1],rect[2]); label_mac_icon(rect[1],rect[2],'VU Machine'); pause_then_erase_text(Pause_between_frames); type_text("I should really touch up those corners∂nBut who needs fatbits, my eye/hand coordination is great!"); touch_up_mac_icon(rect[1],rect[2]); # Create target Mac by copying and pasting VU Machine pause_then_erase_text(Pause_between_frames); type_text("Another machine is needed to run the test against∂n--it requires the Agent VU to be installed"); copy_mac_icon( { rect[1],rect[2] }, { rect[1] + 150,rect[2] } ); label_mac_icon(rect[1] + 150,rect[2],'Target Machine'); # Show a few simple commands pause_then_erase_text(Pause_between_frames); close_tool_pallette(); type_text( "I can do simple things like menu selections∂nFor example, I will execute the following commands for you:∂nselect [menuItem t:'Monaco' m:'Font'];∂nselect [menuItem t:'9 point' m:'Style'];"); select [menuItem t:'Monaco' m:'Font']; select [menuItem t:'9 point' m:'Style']; # Quit the program select[menuitem t:'Quit' m:'File']; wait(1); if match[button t:'No' w:1] select [button t:'No' w:1]; wait(1); if match[button t:'No' w:1] select [button t:'No' w:1]; wait(1);